const path = require('path')
  // 引入html插件
const HTMLWebpackPlugin = require('html-webpack-plugin');
// 引入clean插件
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
module.exports = {
  mode: 'development',
  entry: './src/index.ts',
  output: {
    path: path.resolve(__dirname, './dist'),
    filename: 'bundle.js',
    // 告诉webpack不使用箭头
    environment: {
      arrowFunction: false,
      // 不使用const,此时兼容IE 10
      const: false
    }
  },
  module: {
    rules: [{
        test: /\.ts$/,
        use: [
          'babel-loader',
          'ts-loader'
        ],
        exclude: /node_modules/
      },
      {
        test: /.less$/,
        use: [
          'style-loader',
          'css-loader',
          'postcss-loader',
          'less-loader'
        ],

      }
    ]
  },
  plugins: [
    new CleanWebpackPlugin(),
    new HTMLWebpackPlugin({
      template: "./src/index.html"
    }),
  ],
  // 在导入语句没带文件后缀时，webpack会自动带上后缀去尝试访问文件是否存在。
  // resolve.extensions用于配置在尝试过程中用到的后缀列表，默认是： extensions:['.js', '.json']
  resolve: {
    extensions: ['.ts', '.js']
  }
}